﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WooCoo.ObjectModel.ManagedProperty
{
    public static class PropertyInfoFactory
    {
        private static IPropertyInfoFactory _factory;

        public static IPropertyInfoFactory Factory
        {
            get
            {
                if (_factory == null)
                {
                    var typeName = System.Configuration.ConfigurationManager.AppSettings["PropertyInfoFactory"];
                    if (string.IsNullOrEmpty(typeName))
                    {
                        _factory = new DefaultPropertyInfoFactory();
                    }
                    else
                    {
                        var type = Type.GetType(typeName);
                        _factory = (IPropertyInfoFactory)Activator.CreateInstance(type);
                    }
                }
                return _factory;
            }
            set
            {
                _factory = value;
            }
        }
    }
}
